/**
  window.h - Created by Timothy Morey on 3/7/2012.

  This file contains an mostly OS independent interface to create and control
  a graphical window with an OpenGL drawing surface.
*/

#ifndef __WINDOW_H
#define __WINDOW_H

#include "layer.h"
#include "libnvn.h"

/**
  Adds the layer to the specified window.

  @param window A window handle.
  @param layer A layer handle.

  @return An nvn error code indicating if the operation was successful.
*/
EXPORT int AddLayer(int window, int layer);

/**
  Creates a new window that contains an OpenGL rendering surface.

  @param[in] title The title text for the window.
  @param[in] x The x-position of the top-left corner of the window.
  @param[in] y The y-position of the top-left corner of the window.
  @param[in] width The width of the window, in pixels.
  @param[in] height The height of the window, in pixels.
  @param[in] borderless Indicates if the window should be drawn without 
  borders, as would be desirable for a full-screen window.
  @param[out] window A handle to the new window.

  @return An nvn error code indicating if the operation was successful. If 
  there was an error, error messages will be written to stderr.
*/
EXPORT int CreateGLWindow(char* title, int x, int y, int width, int height, 
                          int borderless, int* window);

/**
  Destroys a window earlier created with CreateGLWindow.

  @param The id of the window that will be destroyed.  After the function
  returns, the id will no longer be valid.

  @return An nvn error code indicating if the operation was successful.
*/
EXPORT int DestroyGLWindow(int window);

/**
  Indicates that the specified window is dirty and must be redrawn.

  @param The id of the window that needs to redraw.

  @return An nvn error code indicating if the operation was successful.
*/
EXPORT int RedrawGLWindow(int window);

/**
  Creates a new thread to manage a UI, and starts the message loop for that
  thread.  This should be called once before any UI windows are used in order
  to initialize the UI system.

  @return An nvn error code indicating if the operation was successful.
*/
EXPORT int StartUIThread();

/**
  Terminates the UI thread and its message loop.  This should be called once 
  when graphical windows are no longer needed in the program.

  @return An nvn error code indicating if the operation was successful.
*/
EXPORT int StopUIThread();

#endif
